import 'package:bxultimate/widgets/mk_page.dart';
import 'package:bxultimate/widgets/mk_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class OrganizationTransferAdminPage extends StatefulWidget {
  const OrganizationTransferAdminPage({Key? key}) : super(key: key);

  @override
  State<OrganizationTransferAdminPage> createState() => _OrganizationTransferAdminPageState();
}

class _OrganizationTransferAdminPageState extends State<OrganizationTransferAdminPage> {
  final controller = Get.find<OrganizationTransferAdminController>();
  final state = Get.find<OrganizationTransferAdminController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: TDNavBar(
            backgroundColor: Colors.transparent,
            title: '转让负责人',
          ),
          body: Obx(()=>MkScrollView(
            bottomButton: TDButton(
              text: '确认转让负责人',
              shape: TDButtonShape.circle,
              height: 48,
              onTap: controller.handleSelect,
              isBlock: true,
              theme: TDButtonTheme.primary,
            ),
            children: [
              TDRadioGroup(
                selectId: controller.currentCheckIdcard,
                onRadioGroupChange: (id) {
                  controller.currentCheckIdcard = id!;
                },
                passThrough: false,
                child: ListView.builder(
                  padding: const EdgeInsets.all(0),
                  shrinkWrap: true,
                  physics: const NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) {
                      return TDRadio(
                        id: state.userList[index].idcard,
                        title: state.userList[index].name,
                        subTitle: state.userList[index].idcard,
                      );
                  },
                  itemCount: state.userList.length,
                ),
              )
            ],
          )),
        ));
  }

  Widget getAllIcon(bool checked, bool halfSelected) {
    return Icon(
        checked ? TDIcons.check_circle_filled : halfSelected ? TDIcons.minus_circle_filled : TDIcons.circle,
        size: 24,
        color: (checked || halfSelected) ? TDTheme.of(context).brandNormalColor : TDTheme.of(context).grayColor4
    );
  }


  @override
  void dispose() {
    Get.delete<OrganizationTransferAdminController>();
    super.dispose();
  }
}